package lt.vin.exaatto.server.guice;

import javax.jdo.PersistenceManager;

import lt.vin.exaatto.server.PMF;
import lt.vin.exaatto.server.RpcServiceImpl;
import lt.vin.exaatto.server.XMPPReceiverServlet;
import lt.vin.exaatto.server.dao.ChatDao;
import lt.vin.exaatto.server.dao.impl.ChatDaoImpl;
import lt.vin.exaatto.server.service.ChatService;
import lt.vin.exaatto.server.service.impl.ChatServiceImpl;

import com.google.appengine.api.xmpp.XMPPService;
import com.google.appengine.api.xmpp.XMPPServiceFactory;
import com.google.inject.servlet.ServletModule;

class ExaAttoServletModule extends ServletModule {
	@Override
	protected void configureServlets() {
		bind(ChatDao.class).to(ChatDaoImpl.class);
		bind(ChatService.class).to(ChatServiceImpl.class);
		
		bind(PersistenceManager.class).toInstance(PMF.get().getPersistenceManager());
		bind(XMPPService.class).toInstance(XMPPServiceFactory.getXMPPService());	
		
		serve("/lt.vin.exaatto.Chat/chat").with(RpcServiceImpl.class);
		serve("/_ah/xmpp/message/chat/").with(XMPPReceiverServlet.class);		
	}
}